﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PalFramework.Template;

namespace PalBattleEmulator.Template.Unit
{
    public class CharacterTmpl : PalObjectTmpl, ICharacterTmpl
    {
        public override void LoadData(Dictionary<string, string> data)
        {
            foreach (string key in data.Keys)
            {
                if(dictionary.ContainsKey(key))
                {
                    int type = dictionary[key];
                    string value = data[key];
                    switch (type)
                    {
                        case ID:
                            Id = Convert.ToInt32(value);
                            break;
                        case NAME:
                            Name = value;
                            break;
                        case SPRITE:
                            Sprite = value;
                            break;
                    }
                }
                
            }
        }

        private string sprite;

        public string Sprite
        {
            get
            {
                return sprite;
            }
            set
            {
                sprite = value;
            }
        }

        private int life;

        public int Life
        {
            get { return life; }
            set { life = value; }
        }

        private int spirit;

        public int Spirit
        {
            get { return spirit; }
            set { spirit = value; }
        }

        private int health;

        public int Health
        {
            get { return health; }
            set { health = value; }
        }

        public const int ID = 0;
        public const int NAME = 1;
        public const int SPRITE = 5;

        private static Dictionary<string, int> dictionary;

        static CharacterTmpl()
        {
            dictionary = new Dictionary<string, int>();
            dictionary.Add("id", ID);
            dictionary.Add("name", NAME);
            dictionary.Add("sprite", SPRITE);
        }

    }
}
